/**
 * @file		common_memory.c
 * @brief		common memory api
 * @note		None
 * @attention	None
 * 
 * <B><I>Copyright 2015 Socionext Inc.</I></B>
 */

//--------------------------------------------------------------
// Header files
//--------------------------------------------------------------
#include <string.h>
#include "common_memory.h"

//--------------------------------------------------------------
// Extern Function
//--------------------------------------------------------------
extern volatile unsigned int* const gTkernel_finished_boot;

//--------------------------------------------------------------
// Definition
//--------------------------------------------------------------

//--------------------------------------------------------------
// Global Function
//--------------------------------------------------------------
void common_memory_set(void)
{
	T_COMMON_MEMORY*	cmn_memory;
	
	cmn_memory = (T_COMMON_MEMORY*)SDRAM_ADR_COMMON_MEMORY;
	memset( cmn_memory, 0, sizeof(T_COMMON_MEMORY) );
	
	cmn_memory->num = SDRAM_SIZ_COMMON_NUM;
	
	cmn_memory->data[0].adr = SDRAM_ADR_COMMON_0;
	cmn_memory->data[0].siz = SDRAM_SIZ_COMMON_0;
	cmn_memory->data[1].adr = SDRAM_ADR_COMMON_1;
	cmn_memory->data[1].siz = SDRAM_SIZ_COMMON_1;
	cmn_memory->data[2].adr = SDRAM_ADR_COMMON_2;
	cmn_memory->data[2].siz = SDRAM_SIZ_COMMON_2;
	cmn_memory->data[3].adr = SDRAM_ADR_COMMON_3;
	cmn_memory->data[3].siz = SDRAM_SIZ_COMMON_3;
	cmn_memory->data[4].adr = SDRAM_ADR_COMMON_4;
	cmn_memory->data[4].siz = SDRAM_SIZ_COMMON_4;
	cmn_memory->data[5].adr = SDRAM_ADR_COMMON_5;
	cmn_memory->data[5].siz = SDRAM_SIZ_COMMON_5;
	cmn_memory->data[6].adr = SDRAM_ADR_COMMON_6;
	cmn_memory->data[6].siz = SDRAM_SIZ_COMMON_6;
	cmn_memory->data[7].adr = SDRAM_ADR_COMMON_7;
	cmn_memory->data[7].siz = SDRAM_SIZ_COMMON_7;
	cmn_memory->data[8].adr = SDRAM_ADR_COMMON_8;
	cmn_memory->data[8].siz = SDRAM_SIZ_COMMON_8;
	cmn_memory->data[9].adr = SDRAM_ADR_COMMON_9;
	cmn_memory->data[9].siz = SDRAM_SIZ_COMMON_9;
	cmn_memory->data[10].adr = SDRAM_ADR_COMMON_10;
	cmn_memory->data[10].siz = SDRAM_SIZ_COMMON_10;
	cmn_memory->data[11].adr = SDRAM_ADR_COMMON_11;
	cmn_memory->data[11].siz = SDRAM_SIZ_COMMON_11;
	cmn_memory->data[12].adr = SDRAM_ADR_COMMON_12;
	cmn_memory->data[12].siz = SDRAM_SIZ_COMMON_12;
	cmn_memory->data[13].adr = SDRAM_ADR_COMMON_13;
	cmn_memory->data[13].siz = SDRAM_SIZ_COMMON_13;
	cmn_memory->data[14].adr = SDRAM_ADR_COMMON_14;
	cmn_memory->data[14].siz = SDRAM_SIZ_COMMON_14;
	cmn_memory->data[15].adr = SDRAM_ADR_COMMON_15;
	cmn_memory->data[15].siz = SDRAM_SIZ_COMMON_15;
	cmn_memory->data[16].adr = SDRAM_ADR_COMMON_16;
	cmn_memory->data[16].siz = SDRAM_SIZ_COMMON_16;
	cmn_memory->data[17].adr = SDRAM_ADR_COMMON_17;
	cmn_memory->data[17].siz = SDRAM_SIZ_COMMON_17;
	cmn_memory->data[18].adr = SDRAM_ADR_COMMON_18;
	cmn_memory->data[18].siz = SDRAM_SIZ_COMMON_18;
	cmn_memory->data[19].adr = SDRAM_ADR_COMMON_19;
	cmn_memory->data[19].siz = SDRAM_SIZ_COMMON_19;
	cmn_memory->data[20].adr = SDRAM_ADR_COMMON_20;
	cmn_memory->data[20].siz = SDRAM_SIZ_COMMON_20;
	cmn_memory->data[21].adr = SDRAM_ADR_COMMON_21;
	cmn_memory->data[21].siz = SDRAM_SIZ_COMMON_21;
	cmn_memory->data[22].adr = SDRAM_ADR_COMMON_22;
	cmn_memory->data[22].siz = SDRAM_SIZ_COMMON_22;
	cmn_memory->data[23].adr = SDRAM_ADR_COMMON_23;
	cmn_memory->data[23].siz = SDRAM_SIZ_COMMON_23;
	cmn_memory->data[24].adr = SDRAM_ADR_COMMON_24;
	cmn_memory->data[24].siz = SDRAM_SIZ_COMMON_24;
	cmn_memory->data[25].adr = SDRAM_ADR_COMMON_25;
	cmn_memory->data[25].siz = SDRAM_SIZ_COMMON_25;
	cmn_memory->data[26].adr = SDRAM_ADR_COMMON_26;
	cmn_memory->data[26].siz = SDRAM_SIZ_COMMON_26;
	cmn_memory->data[27].adr = SDRAM_ADR_COMMON_27;
	cmn_memory->data[27].siz = SDRAM_SIZ_COMMON_27;
	cmn_memory->data[28].adr = SDRAM_ADR_COMMON_28;
	cmn_memory->data[28].siz = SDRAM_SIZ_COMMON_28;
	cmn_memory->data[29].adr = SDRAM_ADR_COMMON_29;
	cmn_memory->data[29].siz = SDRAM_SIZ_COMMON_29;
	cmn_memory->data[30].adr = SDRAM_ADR_COMMON_30;
	cmn_memory->data[30].siz = SDRAM_SIZ_COMMON_30;

	
	{	// for suspend/resume for Linux and RTOS communication
		*gTkernel_finished_boot = 0;//Clear RTOS's finished boot flag
		volatile unsigned int* linux_complite_suspend = (volatile unsigned int*)SDRAM_ADR_LINUX_COMPLITE_SUSPEND;
		*linux_complite_suspend = 0;//Clear the flag
	}
	
	return;
}
